<?php
// Template Name: Trang_chủ
?>
<?php 
show_follow();
?>
<div class="content">

    <div class="content_botbg">

        <div class="content_res">

            <?php //get_template_part('featured'); ?>

            <!-- left block -->
            <div class="content_left">


                <?php if ($cp_options->home_layout == 'directory') { ?>

                    <div class="shadowblock_out">

                    </div><!-- /shadowblock_out -->

                <?php } ?>


                <div class="tabcontrol">

                    <ul class="tabnavig">
                        <li><a href="#block1"><span class="big"><?php _e('Mới nhất', APP_TD); ?></span></a></li>
                        <li><a href="#block2"><span class="big"><?php _e('Xem nhiều', APP_TD); ?></span></a></li>
                        <li><a href="#block3"><span class="big"><?php _e('Ngẫu nhiên', APP_TD); ?></span></a></li>
                    </ul>

                    <?php
//						remove_action( 'appthemes_after_endwhile', 'cp_do_pagination' );
//                                                echo APP_POST_TYPE;
//						$post_type_url = add_query_arg( array( 'paged' => 2 ), get_post_type_archive_link( APP_POST_TYPE ) );
//                                                echo $post_type_url;
                    ?>      


                    <!-- tab 1 -->
                    <div id="block1">

                        <div class="clr"></div>

                        <div class="undertab"><span class="big"><?php _e('Sản phẩm', APP_TD); ?> / <strong><span class="colour"><?php _e('Mới nhất', APP_TD); ?></span></strong></span></div>

                        <?php
                        // show all ads but make sure the sticky featured ads don't show up first
                        $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                        //get product here
                        query_posts(array('post_type' => APP_POST_TYPE, 'ignore_sticky_posts' => 1, 'paged' => $paged));

                        $total_pages = max(1, absint($wp_query->max_num_pages));
                        ?>

                        <?php
                        /* Ok chúng ta sẽ gọi một phần template hiển thị sản phẩm ở đây.
                         * Chú ý sau này sẽ có bộ lọc cho 3 loại: product, post, ask 
                         * Hiện tại chúng ta sẽ lấy theo SẢN PHẨM trước theo tiêu chí:
                         * mới nhất.
                         */

                        get_template_part('loop', 'ad_listing');
                        ?>

                    </div><!-- /block1 -->

                    <!-- tab 2 -->
                    <div id="block2">

                        <div class="clr"></div>

                        <div class="undertab"><span class="big"><?php _e('Sản phẩm', APP_TD); ?> / <strong><span class="colour"><?php _e('Xem nhiều', APP_TD); ?></span></strong></span></div>

                        <?php get_template_part('loop', 'popular'); ?>

                        <?php
                        global $cp_has_next_page;
                        if ($cp_has_next_page) {
                            $popular_url = add_query_arg(array('sort' => 'popular'), $post_type_url);
                            ?>
                            <div class="paging"><a href="<?php echo $popular_url; ?>"> <?php _e('View More Ads', APP_TD); ?> </a></div>
                        <?php } ?>

                        <?php wp_reset_query(); ?>

                    </div><!-- /block2 -->


                    <!-- tab 3 -->
                    <div id="block3">

                        <div class="clr"></div>

                        <div class="undertab"><span class="big"><?php _e('Sản phẩm', APP_TD); ?> / <strong><span class="colour"><?php _e('Ngẫu nhiên', APP_TD); ?></span></strong></span></div>

                        <?php
                        // show all random ads but make sure the sticky featured ads don't show up first
                        $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                        query_posts(array('post_type' => APP_POST_TYPE, 'ignore_sticky_posts' => 1, 'paged' => $paged, 'orderby' => 'rand'));
                        $total_pages = max(1, absint($wp_query->max_num_pages));
                        ?>
                        <?php get_template_part('loop', 'ad_listing'); ?>
                    </div><!-- /block3 -->
                </div><!-- /tabcontrol -->

            </div><!-- /content_left -->


            <?php //get_sidebar(); ?>
            <div class="content_right">
                <div class="shadowblock_out">
                    <div class="shadowblock">
                        <h2 class="colour_top">Danh sách cửa hàng nổi bật</h2>
                    </div><!-- /shadowblock -->
                </div><!-- /shadowblock_out -->
                <div class="shadowblock_out">

                    <div class="shadowblock">
                        <h2 class="colour_top">Danh sách cửa hàng nổi bật</h2>


                        <ul>
                            <li><a href="http://yourstyle.name/raovat/wp-login.php?action=register">Đăng kí</a></li>                  <li><a href="http://yourstyle.name/raovat/?page_id=13">Log in</a></li>
                            <li><a target="_blank" href="http://www.appthemes.com/" title="Premium WordPress Themes">AppThemes</a></li>
                            <li><a target="_blank" href="http://wordpress.org/" title="Powered by WordPress">WordPress</a></li>
                        </ul>

                        <div class="clr"></div>

                    </div>

                </div> 
            </div>
            <div class="clr"></div>
        </div><!-- /content_res -->

    </div><!-- /content_botbg -->

</div><!-- /content -->
